package com.shidaimanong.demo.json;

import com.google.gson.Gson;

public class JsonDemo2 {
    public static void main(String[] args) {
        String jsonStr = "{\"name\":\"赵丽颖\",\"age\":34,\"divorce\":true}";
        Gson gson = new Gson();
        Girl2 girl = gson.fromJson(jsonStr, Girl2.class);
        System.out.println("姓名:" + girl.name);
        System.out.println("年龄:" + girl.age);
        if (girl.divorce) {
            System.out.println("已离婚");
        }
    }
}

class Girl2 {
    public String name;
    public int age;
    public boolean divorce;
}
